from sklearn.datasets import load_iris
from sklearn.decomposition import PCA
data = [[2, 8, 4, 5],
        [6, 3, 0, 8],
        [5, 4, 9, 1]]

# 将三维降成2维
# pca = PCA(n_components=2)
# result =pca.fit_transform(data)
# print(result)
# [[  1.28620952e-15   3.82970843e+00]
#  [  5.74456265e+00  -1.91485422e+00]
 # [ -5.74456265e+00  -1.91485422e+00]]



# 对鸢尾花的数据进行降维
iris = load_iris()
print(iris.data[:2])
# [[ 5.1  3.5  1.4  0.2]
#  [ 4.9  3.   1.4  0.2]]
pca = PCA(n_components=2)
result = pca.fit_transform(iris.data)
print(result[:2])
# [[-2.68420713  0.32660731]
#  [-2.71539062 -0.16955685]]


